package com.nit.generate;

import com.nit.tools.loop.NitLoopTools;

/**
 * 生肖 生成器
 *
 * @Auth: 逆天开源-逍遥哥哥
 * @link: 1715656022@qq.com
 * @Date: 2023-11-13
 */
public class NitZodiacGenerator {
    private static final String[] ZODIACS_ARRAY = new String[]{"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};


    public static String generate() {
        return ZODIACS_ARRAY[NitNumberGenerator.generateInt(1, 12)];
    }

    /**
     * 根据年份计算生肖
     *
     * @param year
     * @return
     */
    public static String getChineseZodiac(int year) {
        return year < 1900 ? null : ZODIACS_ARRAY[(year - 1900) % ZODIACS_ARRAY.length];
    }

    public static void main(String[] args) {
        NitLoopTools.loop(40, () -> {
            String tmp = NitZodiacGenerator.generate();
            System.out.println("随机生肖:" + tmp + "<br>");
        });

        System.out.println("计算:" + NitZodiacGenerator.getChineseZodiac(1985) + "<br>");
    }

}
